from selenium import webdriver
import traceback
from pprint import pprint


class PrefOp:
    shared_wd = None

    def openBrowser(self, browser='chrome'):
        if PrefOp.shared_wd:
            return
        try:
            if browser == 'chrome':
                PrefOp.shared_wd = webdriver.Chrome()
            elif browser == 'firefox':
                PrefOp.shared_wd = webdriver.Firefox()
            else:
                PrefOp.shared_wd = webdriver.Ie()

            PrefOp.shared_wd.implicitly_wait(5)
        except:
            pprint(traceback.format_exc())

    def closeBrowser(self):
        PrefOp.shared_wd.quit()

